# SPDX-FileCopyrightText: 2025 MounRiver Studio <https://mounriverstudio.com/>
# SPDX-License-Identifier: BSD-3-Clause
# Author: Azolla <https://gitee.com/azolla/>
# Date: 2025-04-21

# Enable CMake support for ASM and C languages
enable_language(C ASM)
 
# 创建一个(接口库 INTERFACE)/(静态库 STATIC)/(动态库 SHARED)
add_library(FreeRTOS INTERFACE)

message(STATUS "Building FreeRTOS...")

target_sources(FreeRTOS INTERFACE
    ${CMAKE_CURRENT_LIST_DIR}/croutine.c
    ${CMAKE_CURRENT_LIST_DIR}/event_groups.c
    ${CMAKE_CURRENT_LIST_DIR}/list.c
    ${CMAKE_CURRENT_LIST_DIR}/queue.c
    ${CMAKE_CURRENT_LIST_DIR}/tasks.c
    ${CMAKE_CURRENT_LIST_DIR}/timers.c
    # ${CMAKE_CURRENT_LIST_DIR}/portable/Common/mpu_wrappers.c
    ${CMAKE_CURRENT_LIST_DIR}/portable/MemMang/heap_4.c
    ${CMAKE_CURRENT_LIST_DIR}/portable/GCC/RISC-V/port.c
    ${CMAKE_CURRENT_LIST_DIR}/portable/GCC/RISC-V/portASM.S
)

target_include_directories(FreeRTOS INTERFACE
    ${CMAKE_CURRENT_LIST_DIR}/include
    ${CMAKE_CURRENT_LIST_DIR}/portable/GCC/RISC-V
    ${CMAKE_CURRENT_LIST_DIR}/portable/GCC/RISC-V/chip_specific_extensions/RV32I_PFIC_no_extensions
    ${CMAKE_SOURCE_DIR}/ # 包含 主CMakeLists.txt 目录的头文件
)
# message(STATUS "Building FreeRTOS done. ${CMAKE_SOURCE_DIR}")